﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ball : MonoBehaviour
{
    public float force = 5;
    Rigidbody2D rigid;
    public float Scale
    {
        get =>
             transform.GetChild(0).localScale.x ;
        set
        {
            transform.GetChild(0).localScale = Vector3.one * value;
        }
        
    }
    // Start is called before the first frame update
    void Start()

    {
        rigid = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
  
        rigid.AddForce( -transform.localPosition * force);
        if(transform.parent.GetComponent<Rigidbody2D>() is Rigidbody2D r){
        //    r.AddForce(transform.localPosition * force);
        }
    }
}
